
define(['ionic', 'utility'], function () {
    angular.module('U9Mobile.utility')
        .factory('DuDuUtil', ['$q', '$http', 'ConnectService', 'AppConstants',
            function ($q, $http, ConnectService, AppConstants) {
                var o = {};

                o.createConference = function (userId, caller, phones) {
                    var defer = $q.defer();

                    var url = AppConstants.CREATE_CPNDERENCE_URL.format({
                        address: ConnectService.getConnect('address'),
                        port: ConnectService.getConnect('port'),
                        caller: caller,
                        phones: phones,
                        userId: userId
                    });
                    $http({
                        method: 'Get',
                        url: url,
                        timeout: AppConstants.HTTP_TIME_OUT
                    }).success(function (data) {
                        if (data.result === '0') {
                            defer.resolve(data);
                        } else {
                            defer.reject();
                        }
                    }).error(function () {
                        defer.reject();
                    });

                    return defer.promise;
                };

                return o;
            }
        ]);
});